<div class="tabbable tabs-left">
              <ul class="nav nav-tabs">
              	<li><h5><?php echo $this->translate('库存状态'); ?></h5></li>
                <li class="active"><a data-toggle="tab" href="#express_a"><?php echo $this->translate('基本信息'); ?></a></li>
              </ul>
              <form class="form-horizontal" name="stock_state_form" id="stock_state_form" method="post" action="">
              <input type="hidden" name="stock_state_id" id="stock_state_id" value="<?php if($this->stock_state_info) echo $this->stock_state_info->stock_state_id; else echo ''; ?>" />
              <input type="hidden" name="state_type" id="state_type" value="<?php if($this->stock_state_info) echo $this->stock_state_info->state_type; ?>" />
              <div class="tab-content">
    			<div id="sticky_navigation" style="height:30px;border-bottom:4px solid #DFDFDF;">
        			<div class="pull-left" style="font-size:16px;line-height:30px;"><strong><?php if($this->stock_state_info) echo $this->translate('编辑'); else echo $this->translate('新加'); ?><?php echo $this->translate('库存状态'); ?></strong></div>
        			<div class="pull-right">
                	<a href="<?php echo $this->url('stock_state/default'); ?>" class="btn btn-small"><i class="icon-arrow-left"></i> <?php echo $this->translate('返回库存状态列表'); ?></a>&nbsp;
                	<a href="<?php echo $this->serverUrl(true); ?>" class="btn btn-small btn-warning"><i class="icon-repeat icon-white"></i> <?php echo $this->translate('刷新'); ?></a>&nbsp;
                    <?php if($this->stock_state_info and $this->stock_state_info->state_type != 1) { ?>
                    <a href="javascript:;" onclick="return stock_state_del_js(<?php echo $this->stock_state_info->stock_state_id ?>);" class="btn btn-small btn-danger"><i class="icon-remove icon-white"></i> <?php echo $this->translate('删除库存状态'); ?></a>&nbsp;
                    <?php } ?>
                	<button type="submit" class="btn btn-small btn-primary"><i class="icon-ok icon-white"></i> <?php echo $this->translate('保存库存状态信息'); ?></button>&nbsp;
                	<a href="<?php echo $this->myviewalias()->dbshopHelpUrl('state_set'); ?>" target="_blank" class="btn btn-small btn-info"><i class="icon-info-sign icon-white"></i> <?php echo $this->translate('查看帮助说明'); ?></a>
                	</div>
        		</div>
                <div id="express_a" class="tab-pane active">
                	<div class="well admin_add_header_well"><?php echo $this->translate('基本信息'); ?></div>
                	<div class="well admin_add_well">
                     	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('状态类型'); ?>：</label>
           					<div class="controls">
              					<select class="span2" name="stock_type_state" id="stock_type_state">
                                	<option value="1" <?php if($this->stock_state_info and $this->stock_state_info->stock_type_state==1) echo 'selected="selected"'; ?>><?php echo $this->translate('有货状态'); ?></option>
                                    <option value="2" <?php if($this->stock_state_info and $this->stock_state_info->stock_type_state==2) echo 'selected="selected"'; ?>><?php echo $this->translate('无货状态'); ?></option>
                                </select>
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('库存状态名称'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
              					<input type="text" id="stock_state_name"  name="stock_state_name" class="span6" value="<?php echo ($this->stock_state_info ? $this->escapeHtml($this->stock_state_info->stock_state_name) : ''); ?>">
            				</div>                        
                        </div>
                    	<div class="control-group">
                  			<label for="input01" class="control-label"><?php echo $this->translate('库存状态排序'); ?><span class="must_add_value">*</span>：</label>
           					<div class="controls">
              					<input type="text" class="span1" name="state_sort" id="state_sort" value="<?php echo ($this->stock_state_info ? $this->stock_state_info->state_sort : 255); ?>" />
            				</div>                        
                        </div>
                                                                                                                                               
                  	</div>
                </div>
                                
                
             </div>
              </form>
</div>
<script>
$(document).ready(function() {
	$("#stock_state_form").validate({
		rules: {
			stock_state_name: {
				required: true,
				maxlength:60
			},
			stock_state_sort: {
				required: true,
				number: true,
				min:1,
				max:255
			}
		},
		messages: {
			stock_state_name: {
				required: "<?php echo $this->translate('库存状态名称不能为空！'); ?>",
				maxlength: "<?php echo $this->translate('库存状态名称最多输入30个汉字！'); ?>"
			},
			stock_state_sort: {
				required: "<?php echo $this->translate('库存状态排序不能为空！'); ?>",
				number: "<?php echo $this->translate('库存状态排序必须为数字！'); ?>",
				min: "<?php echo $this->translate('库存状态排序最小为1！'); ?>",
				max: "<?php echo $this->translate('库存状态排序最大为255！'); ?>"
			}
		}
	});
});

//库存状态删除js
function stock_state_del_js(stock_state_id) {
	if(window.confirm('<?php echo $this->translate('您确实要删除该库存状态吗？'); ?>')) {
	$.post("<?php echo $this->url('stock_state/default',array('action'=>'del')); ?>",{stock_state_id:stock_state_id},
	function(data){
		if(data != 'false') {
			if(data == 'goods_exists') {
				alert('<?php echo $this->translate('该库存状态在商品中已经使用，不能删除！'); ?>');
				return false;	
			}
			window.location.href='<?php echo $this->url('stock_state/default'); ?>';
			return true;
		} else {
			alert('<?php echo $this->translate('库存状态删除失败！'); ?>');
		}
	});
	}
	return false;
}
</script>